home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / windows / mrun211.zip / MRUN211B.WAS < prev    next >
Text File  |  1993-05-01  |  10KB  |  394 lines

  1. ;MailRun v2.11:  Part B, changesettings
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4. #comment
  5. **************************************************************************
  6. **************************************************************************
  7. * This file contains routines related to changing MailRun
  8. * settings.  It puts up the MailRun Settings dialog box, and
  9. * writes any changes to the *.MRN file.  If the user changes
  10. * the MailRun directory, it will move all MailRun Files to the
  11. * new directory and stop the script.
  12. **************************************************************************
  13. **************************************************************************
  14. #endcomment
  15.  
  16. #define MRUN211B
  17. #define MRUN211BC
  18. #define MRUN211AB
  19.  
  20. #include "mrun211.h"
  21.  
  22. #comment
  23. *********************************************************************
  24. * MAIN()
  25. * Calls checkchild(), checkdir(), settingsbox(), getfirstitem(),
  26. * loadsettings(), changemailrun(), makemailrunlist(),
  27. * menudim(), newmailrun(), interfaceon(), changemrundir(),
  28. * writesettings(), findstring(), checkchanged(),
  29. * Allows the user to change the settings in the [MailRun]
  30. * section of the *.MRN file.
  31. *********************************************************************
  32. #endcomment
  33.  
  34. proc main
  35. string LastMRunDir, LastMailDir, LastReplyDir
  36. string LastDLDir, LastULDir, LastMRun
  37. integer dialogstatus
  38.     menudim()
  39.     checkchild()
  40.     LastMRun = MailRun
  41.     loadsettings(MailRun)
  42.     LastMailDir = MailDir
  43.     LastReplyDir = ReplyDir
  44.     LastDLDir = DownloadDir
  45.     LastULDir = UploadDir
  46.     if FLAGS & DEFAULTS
  47.         MailRunList = "mailrun.ini"
  48.         MailRunTrunc = "mailrun.ini"
  49.         LastMRunDir = MailRunDir
  50.     else
  51.         findfirst MailRun
  52.         MailRunTrunc = $FILENAME
  53.         makemailrunlist()
  54.     endif
  55.     FLAGS &= UNCHANGED
  56.     settingsbox()
  57.     if !(FLAGS & DEFAULTS)
  58.         disable CTRL 242
  59.     endif
  60.     if LogRun == 0
  61.         disable CTRL 71
  62.         disable CTRL 72
  63.     endif
  64.     if FLAGS & RUNNING
  65.         disable CTRL 170
  66.     endif
  67.     if FLAGS & NEW
  68.         newmailrun()
  69.         getfirstitem()
  70.         LastMRun = MailRun
  71.     endif
  72.     interfaceon()
  73.     while 1
  74.         dialogstatus = $DIALOG
  75.         switch dialogstatus
  76.             case 10
  77.                 ;User selected "Save"
  78.                 ;if the directories chosen in settingsbox()
  79.                 ;don't exist, create them
  80.                 if checkdir(&MailRunDir, LastMRunDir) && \
  81.                     checkdir(&MailDir, LastMailDir) && \
  82.                     checkdir(&ReplyDir, LastReplyDir) && \
  83.                     checkdir(&DownloadDir, LastDLDir) && \
  84.                     checkdir(&UploadDir, LastULDir)
  85.                     ;if all directories were successfully created...
  86.                     chdir MailRunDir
  87.                     if FLAGS & DEFAULTS
  88.                         writesettings(MailRunIni)
  89.                     else
  90.                         writesettings(MailRun)
  91.                     endif
  92.                 else
  93.                     updatedlg 128
  94.                 endif
  95.                 FLAGS &= UNCHANGED
  96.             endcase
  97.             case 11
  98.                 ;User selected "Done"
  99.                 if checkchanged()
  100.                     ;if user has no unsaved changes...
  101.                     if (FLAGS & DEFAULTS) && !(findstring(LastMRunDir, MailRunDir))
  102.                         ;if user has changed the MailRun Directory    
  103.                         changemrundir(LastMRunDir)
  104.                         updatedlg 128
  105.                     else
  106.                         exit
  107.                     endif
  108.                 endif
  109.             endcase
  110.             case 70
  111.                 ;User selected the Log MailRun checkbox
  112.                 if LogRun == 0
  113.                     ;If logging was turned off, disable the other checkboxes
  114.                     disable CTRL 71
  115.                     disable CTRL 72
  116.                 else
  117.                     ;Otherwise, enable the checkboxes
  118.                     enable CTRL 71
  119.                     enable CTRL 72
  120.                 endif
  121.                 FLAGS |= CHANGED
  122.                 updatedlg 1
  123.             endcase
  124.             case 170
  125.                 ;User changed mailrun with combobox
  126.                 if checkchanged()
  127.                     changemailrun()
  128.                     getfirstitem()
  129.                     LastMRun = MailRun
  130.                     updatedlg -1
  131.                 else
  132.                     findfirst MailRun
  133.                     MailRunTrunc = $FILENAME
  134.                     updatedlg 512
  135.                 endif
  136.             endcase
  137.             case 230
  138.             case 231
  139.             case 232
  140.             case 233
  141.             case 234
  142.             case 235
  143.             case 236
  144.             case 237
  145.             case 238
  146.             case 239
  147.             case 240
  148.             case 241
  149.             case 242
  150.             case 71
  151.             case 72
  152.             case 73
  153.                 FLAGS |= CHANGED
  154.             endcase
  155.         endswitch
  156.     endwhile
  157. endproc
  158.  
  159.  
  160. #comment
  161. *********************************************************************
  162. * CHECKDIR()
  163. * Called by main()
  164. * Creates a directory.  If the directory already exists or
  165. * was successfully created, a value of 0 is returned.  If
  166. * an error occurs, the name of NewDir is changed to that
  167. * of OldDir, and a value of 1 is returned.
  168. *********************************************************************
  169. #endcomment
  170.  
  171. func checkdir : integer
  172. strparm NewDir, OldDir
  173.     chdir NewDir
  174.     if FAILURE
  175.         mkdir NewDir
  176.         if FAILURE
  177.             usermsg "Unable to create directory %s" NewDir
  178.             NewDir = OldDir
  179.             return 0
  180.         endif
  181.     endif
  182.     return 1
  183. endfunc
  184.  
  185.  
  186. #comment
  187. *********************************************************************
  188. * NEWMAILRUN()
  189. * Called by main()
  190. * Calls fverify(), filesave(), makemrn(), makemailrunlist(),
  191. * makefullname()
  192. * Prompts the user for the name of a new *.MRN file, checks
  193. * the name, and calls routines to create it.
  194. *********************************************************************
  195. #endcomment
  196.  
  197. proc newmailrun
  198. string NewRun, temp
  199.     ;Make sure the entered MailRun ID is the correct length
  200.     ;and that it doesn't already exist
  201.     while 1
  202.         NewRun = ""
  203.         sdlginput "New MailRun" \
  204.             "Enter the ID of the new mailrun:" NewRun
  205.         if FAILURE
  206.             exit
  207.         endif
  208.         strlwr NewRun
  209.         if not fverify(NewRun)
  210.             usermsg \
  211.             "A mailrun ID must be a valid DOS file name without the extension."
  212.             loopwhile
  213.         endif
  214.         strfmt temp "%s.mrn" NewRun
  215.         NewRun = makefullname(MailRunDir, temp)
  216.         if isfile NewRun
  217.             errormsg "That MailRun already exists!"
  218.         else
  219.             exitwhile
  220.         endif
  221.     endwhile
  222.  
  223.     ;Update the previous mailrun
  224.     filesave()
  225.     delfile MailRun
  226.     ;Create the new mailrun
  227.     MailRunTrunc = temp
  228.     makemrn()
  229.     makemailrunlist()
  230.     updatedlg -1
  231. endproc
  232.  
  233.  
  234. #comment
  235. *********************************************************************
  236. * CHANGEMRUNDIR()
  237. * Called by main()
  238. * Calls movefiles(), fileexit(), makefullname()
  239. * Requests confirmation, moves all MailRun support files
  240. * to the new MailRun Directory, and shuts down so that the
  241. * user can restart.
  242. *********************************************************************
  243. #endcomment
  244.  
  245. proc changemrundir
  246. strparm LastMRunDir
  247. string WarnMsg, CleanupFile
  248. integer Response
  249.     strfmt WarnMsg "All MailRun files will be moved to`r`n`r`n\
  250.       %s`r`n`r`nand MailRun will have to be restarted.`r`n`r`nDo you wish \
  251. continue?" MailRunDir
  252.     sdlgmsgbox "MailRun Message" WarnMsg QUESTION YESNO Response 2
  253.     switch Response
  254.         case 6
  255.             ;User selected "Yes"
  256.             cleanupfile = makefullname(TempDir, "CLEANUP.TMP")
  257.             profilerd cleanupfile "cleanup" "LastMRun" MailRun
  258.             findfirst MailRun
  259.             MailRunTrunc = $FILENAME
  260.             profilewr MailRunIni "MailRun" "MailRunDir" MailRunDir
  261.             movefiles(LastMRunDir, MailRunDir, "MRUN211?.WA?")
  262.             movefiles(LastMRunDir, MailRunDir, "MRUN211.H")
  263.             movefiles(LastMRunDir, MailRunDir, "NEWFILES.WA?")
  264.             movefiles(LastMRunDir, MailRunDir, "TERMINAL.WA?")
  265.             movefiles(LastMRunDir, MailRunDir, "*.MRN")
  266.             movefiles(LastMRunDir, MailRunDir, "*.?DX")
  267.             movefiles(LastMRunDir, MailRunDir, "*.?BF")
  268.             movefiles(LastMRunDir, MailRunDir, "MRUNICON.DLL")
  269.             movefiles(LastMRunDir, MailRunDir, "MAILRUN.WRI")
  270.             fileexit()
  271.         endcase
  272.         case 7
  273.             ;User selected "No"
  274.             MailRunDir = LastMRunDir
  275.         endcase
  276.     endswitch
  277. endproc    
  278.  
  279.  
  280. #comment
  281. *********************************************************************
  282. * MOVEFILES()
  283. * Called by changemrundir()
  284. * Calls makefullname()
  285. * Moves files matching the given filespec from their current
  286. * location to the MailRun directory.
  287. *********************************************************************
  288. #endcomment
  289.  
  290. proc movefiles
  291. strparm OldDir, NewDir, Spec
  292. string OldFile, NewFile, OldSpec
  293.     OldSpec = makefullname(OldDir, Spec)
  294.     findfirst OldSpec
  295.     while FOUND
  296.         if not strcmpi $FILENAME "MRUN211.WAS"
  297.             if not strcmpi $FILENAME "MRUN211.WAX"
  298.                statmsg "Moving %s" $FILENAME
  299.                 OldFile = makefullname(OldDir, $FILENAME)
  300.                 NewFile = makefullname(NewDir, $FILENAME)
  301.                 copyfile OldFile NewFile
  302.                 delfile OldFile
  303.             endif
  304.         endif
  305.         findnext
  306.     endwhile
  307. endproc
  308.  
  309.  
  310. #comment
  311. *********************************************************************
  312. * SETTINGSBOX()
  313. * Called by main()
  314. * Displays the MailRun Settings dialog box.
  315. *********************************************************************
  316. #endcomment
  317.  
  318. proc settingsbox
  319. destroydlg
  320. HelpPage = 4
  321. dialogbox 15 36 340 222 15 "MailRun Settings" HELPID HelpPage
  322.    groupbox 10 28 200 96 "Directories" shadow
  323.    text  16 42 71 8 right "MailRun Directory:"
  324.    text  16 58 71 8 right "Mail Directory:"
  325.    text  16 74 71 8 right "Reply Directory:"
  326.    text  16 90 71 8 right "Download Directory:"
  327.    text  16 106 71 8 right "Upload Directory:"
  328.    editbox 91 56 110 12 MailDir
  329.    editbox 91 72 110 12 ReplyDir
  330.    editbox 91 88 110 12 DownloadDir
  331.    editbox 91 104 110 12 UploadDir
  332.    groupbox 224 28 102 96 "Parameters" shadow
  333.    text  234 42 62 8 right "Dial Attempts:"
  334.    text  234 58 62 8 right "Dial Timeout:"
  335.    text  234 74 62 8 right "Dial Pause:"
  336.    text  234 90 62 8 right "Idle Timeout:"
  337.    text  234 106 62 8 right "Packets to Save:"
  338.    editbox 300 40 16 12 DialAttempts
  339.    editbox 300 56 16 12 DialTimeout
  340.    editbox 300 72 16 12 DialPause
  341.    editbox 300 88 16 12 IdleTime
  342.    editbox 300 104 16 12 SavePackets
  343.    groupbox 10 132 124 59 "Logging" shadow
  344.    checkbox 18 144 112 12 "Capture mailrun to log file" LogRun
  345.    checkbox 18 158 112 12 "Append to existing log file" AppendLog
  346.    checkbox 18 172 112 12 "Capture ANSI codes in log file" AnsiInLog
  347.    checkbox 18 200 134 12 "Filter duplicates from d/l database" NewfileFilter
  348.    groupbox 144 132 184 59 "Utilities" shadow
  349.    text  145 146 65 8 right "Archive Utility:"
  350.    text  145 160 65 8 right "QWK Mail Reader:"
  351.    text  145 174 65 8 right "Log File Viewer:"
  352.    editbox 214 144 107 12 Archiver
  353.    editbox 214 158 107 12 QWKReader
  354.    editbox 214 172 107 12 LogViewer
  355.    pushbutton 191 200 40 14 "&Save" normal default
  356.    pushbutton 252 200 40 14 "&Done" normal
  357.    text  100 11 52 8 right "Settings for:"
  358.    combobox 156 9 72 42 MailRunList MailRunTrunc sort
  359.    editbox 91 40 110 12 MailRunDir
  360. enddialog
  361. endproc
  362.  
  363.  
  364.  
  365.